package com.dictionary.hi;

import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.widget.ViewAnimator;

import com.custom.tab.AbstractTabActivity;
import com.custom.tab.AbstractTabRootManager;
import com.inapp.util.BillingService;

public class TabRootManager extends AbstractTabRootManager{

	public TabRootManager(AbstractTabActivity activity,LayoutInflater layoutInflater, ViewAnimator viewAnimator,
			int index) {
		super(activity, layoutInflater, viewAnimator);
		try {
			Bundle bundle = new Bundle();
			switch (index) {
			case 4:
				
				boolean isProVersion = BillingService.isPurchased(
						getSharedPreferences(), Extra.IN_APP_PRODUCT_ID)
						|| getActivity().getPackageName().endsWith("pro");
				String url = isProVersion ? getActivity().getString(R.string.category_images_url_pro)
						: getActivity().getString(R.string.category_images_url);
				
				bundle.putString(ShowCategoryViewController.KEY_CATEGORY_URL,url + 11);
				String resp = activity.getIntent().getStringExtra(Extra.NEWEST_RESP);
				if(resp != null){
					bundle.putString(ShowCategoryViewController.KEY_CATEGORY_DATA, resp);
					bundle.putInt(ShowCategoryViewController.KEY_LOAD_TYPE, ShowCategoryViewController.LOAD_TYPE_DATA);
				}else{
					bundle.putInt(ShowCategoryViewController.KEY_LOAD_TYPE, ShowCategoryViewController.LOAD_TYPE_URL);
				}
				pushViewController(new ShowCategoryViewController(this,bundle));
				break;
			case 3:
				
				pushViewController(new CategoriesViewController(this,bundle));
				break;
			case 2:
				pushViewController(new FavoritesViewController(this,bundle));
				break;
			case 1:
				pushViewController(new UploadViewController(this,bundle));
				break;
			case 0:
				pushViewController(new AboutViewController(this,bundle));
				break;
			default:
				break;
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}
